<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + request.getContextPath() + "/";
%>
<html>
	<head>
		<base href="<%=basePath%>">
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>作者登录</title>
		<link rel="icon" href="images/icon.gif" type="image/x-ico">
		<link href="css/bootstrap.css" rel='stylesheet' type='text/css'/>
		<link href="css/style.css" rel='stylesheet' type='text/css'/>
		<link rel="stylesheet" href="css/nav.css">
		<link rel="stylesheet" href="iocnfont/iconfont.css">
		<link rel="stylesheet" href="css/gototop.css">
		<script type="text/javascript" src="js/jquery-1.11.1.min.js"></script>
		<script src="js/date.js"></script>
		<script>
            $(function () {
                //如果当前的窗口不是顶层窗口,	就把当前窗口设置成顶层窗口
                if (window.top !== window) {
                    window.top.location = window.location;
                }

                //页面加载完毕后,将用户文本框中的内容清空
                $("#username").val("");

                //在页面加载完毕后,让用户的文本框自动获得焦点
                $("#username").focus();

                //为登录提交按钮绑定事件
                $("#submitBtn").click(function () {
                    login();
                })

                //为当前登录页窗口绑定键盘敲击事件
                $(window).keydown(function (event) {
                    if (event.keyCode === 13) {
                        login();
                    }
                })
            })

            function login() {
                //验证账号不能为空
                //取得账号密码
                //将文本中的左右空格去掉,使用$.trim(文本)
                var username = $.trim($("#username").val());
                var password = $.trim($("#password").val());

                if (username === "" || password === "") {
                    $("#msg").html("账号或密码不能为空");

                    //如果账号密码为空,则需要及时强制终止该方法
                    return false;
                }
                $.ajax({
                    url: "author/login.do",
                    data: {
                        "username": username,
                        "password": password
                    },
                    type: "post",
                    dataType: "json",
                    success: function (data) {
                        if (data.success) {
                            window.location.href = "jsp/author/index.jsp";
                        } else {
                            $("#msg").html(data.msg);
                        }
                    }
                })
            }
		</script>
	</head>
	<body>
		<!--登录页面 -->
		<div class="col-lg-9 col-md-9 col-xs-9 col-sm-9 center">
			<div class="dreamcrub">
				<ul class="breadcrumbs">
					<li class="home">
						<a href="index.html" title="返回首页">首页</a>&nbsp;
						<span>&gt;</span>
					</li>
					<li class="pickup">
						作者登录
					</li>
				</ul>
				<ul class="previous">
					<li><a href="index.html" title="返回首页">返回首页</a></li>
				</ul>
				<div class="clearfix"></div>
			</div>
			<div class="register">
				<div class="col-lg-6 col-md-6 col-xs-6 col-sm-6 login-right">
					<h3>已注册作者</h3>
					<p>如果您已有账户，请登录.</p>
					<form >
						<div>
							<span>作者用户名<label>*</label></span>
							<input type="text" placeholder="用户名" id="username">
						</div>
						<div>
							<span>密码<label>*</label></span>
							<input type="password"  placeholder="密码"  id="password"  style="border: 1px solid #DDDBDB;outline-color:#fb4d01;width: 96%;font-size:0.8125em;padding:10px;">
						</div>
						<div class="checkbox" style="position: relative;top: 5px; left: 10px;">
							<span id="msg" style="color: red"></span>
						</div>
						<input type="button" value="登录" id="submitBtn"
							   style="background:#ff0d40;color: #FFF;font-size: 0.8em;padding: 0.7em 1.2em;transition: 0.5s all;display: inline-block;text-transform: uppercase;border:none;outline:none;">
						<a class="forgot" href="#">忘记密码?</a>
					</form>
				</div>
				<div class="col-lg-6 col-md-6 col-xs-6 col-sm-6 login-left">
					<h3>新作者</h3>
					<p>创建一个新账户</p>
					<a class="acount-btn" href="jsp/author/register.jsp">创建账户</a>
				</div>
				<div class="clearfix"></div>
			</div>
		</div>
		<div class="clearfix"></div>
		</div>
	</body>
</html>